var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/";


function insertMany(collection,query){
    MongoClient.connect(url, function(err, db) {
        if (err) throw err;
        var dbo = db.db("mongo");
        var myobj =  query;
        dbo.collection(collection).insertMany(myobj, function(err, res) {
            if (err) throw err;
            console.log("插入的文档数量为: " + res.insertedCount);
            db.close();
        });
    });
}

module.exports = insertMany